import top.yqingyu.common.utils.LocalDateTimeUtil;
import top.yqingyu.qymsg.Dict;
import top.yqingyu.qymsg.MsgHelper;
import top.yqingyu.qymsg.QyMsg;
import top.yqingyu.qymsg.bean.StringKey;
import top.yqingyu.trans$client.api.Connection;
import top.yqingyu.trans$client.api.ConnectionConfig;
import top.yqingyu.trans$client.api.ConnectionFactory;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class aaaa {
    public static void main(String[] args) throws Exception {
        ConnectionConfig config = new ConnectionConfig.Builder(ConnectionConfig.Type.INSTANCE)
                .HOST("192.168.50.67")
                .Pool_max(1)
                .Pool_min(1)
                .build();
        ConnectionFactory factory = new ConnectionFactory(config);

        QyMsg normalMsg = config.NORMAL_MSG;
        StringKey get = StringKey.get("root_file");
        StringKey add = StringKey.add("root_file", "yyj");
        QyMsg clone = normalMsg.clone();
        clone.putMsg("link -s");
        Connection connection = factory.getConnection();
        LocalDateTime now = LocalDateTime.now();
        QyMsg qyMsg = connection.get(clone.putMsgData(Dict.KEY_CMD, get));
        System.out.println(LocalDateTimeUtil.between(now, LocalDateTime.now(), ChronoUnit.MICROS));
        System.out.println(MsgHelper.gainMsg(qyMsg));


        now = LocalDateTime.now();
        qyMsg = connection.get(clone.putMsgData(Dict.KEY_CMD, get));
        System.out.println(LocalDateTimeUtil.between(now, LocalDateTime.now(), ChronoUnit.MILLIS));
        System.out.println(MsgHelper.gainMsg(qyMsg));
//
//        now = LocalDateTime.now();
//        qyMsg = factory.getConnection().get(clone.putMsgData(Dict.KEY_CMD, add));
//        System.out.println(qyMsg);
//        System.out.println(LocalDateTimeUtil.between(now, LocalDateTime.now()));
//
//        now = LocalDateTime.now();
//        qyMsg = factory.getConnection().get(clone.putMsgData(Dict.KEY_CMD, get));
//        System.out.println(qyMsg);
//        System.out.println(LocalDateTimeUtil.between(now, LocalDateTime.now()));
//
//
//        now = LocalDateTime.now();
//        qyMsg = factory.getConnection().get(clone.putMsgData(Dict.KEY_CMD, add));
//        System.out.println(qyMsg);
//        System.out.println(LocalDateTimeUtil.between(now, LocalDateTime.now()));
//
//
//        for (int i = 0; i < 128; i++) {
//            new Thread(() -> {
//                try {
//                    while (true) {
//                        LocalDateTime now2 = LocalDateTime.now();
//                        QyMsg qyMsg2 = factory.getConnection().get(clone.putMsgData(Dict.KEY_CMD, get));
//                        System.out.println(qyMsg2);
//                        System.out.println(LocalDateTimeUtil.between(now2, LocalDateTime.now()));
//                    }
//                } catch (Exception e) {
//                    throw new RuntimeException(e);
//                }
//            }).start();
    }

}
